#ifndef UTILS_H
#define UTILS_H

#include <QtCore>

class Utils
{
public:

	/**
	 * Suma kontrolna MD5 dla podanego pliku
	 **/
	static QByteArray md5sum(const QString & path) {
		QCryptographicHash crypt(QCryptographicHash::Md5);
		QFile f(path);
		QByteArray buf;

		f.open(QIODevice::ReadOnly);

		do {
			buf = f.read(1024);
			crypt.addData(buf);
			//QCoreApplication::processEvents();
		} while(buf.size() > 0);

		f.close();

		return crypt.result();
	}

	static QByteArray md5sum(const QByteArray & ba) {
		QCryptographicHash crypt(QCryptographicHash::Md5);

		crypt.addData(ba);

		return crypt.result();
	}
};

#endif // UTILS_H
